package org.code.boot.controller.boot;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.code.boot.common.annotation.Log;
import org.code.boot.common.enums.BusinessType;
import org.code.boot.controller.BaseController;
import org.code.boot.vo.AjaxResult;
import org.code.boot.domain.boot.BizHotel;
import org.code.boot.service.boot.IBizHotelService;
import org.code.boot.vo.TableDataInfo;

/**
 * 酒店信息Controller
 * 
 * @author coder
 * @date 2025-08-28
 */
@RestController
@RequestMapping("/boot/hotel")
public class BizHotelController extends BaseController
{
    @Autowired
    private IBizHotelService bizHotelService;

    /**
     * 查询酒店信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BizHotel bizHotel)
    {
        startPage();
        List<BizHotel> list = bizHotelService.selectBizHotelList(bizHotel);
        return getDataTable(list);
    }



    /**
     * 获取酒店信息下拉选项列表
     */
    @GetMapping("/options")
    public AjaxResult getOptions()
    {
        List<BizHotel> list = bizHotelService.selectBizHotelList(new BizHotel());
        return success(list);
    }

    /**
     * 获取所有省份列表
     */
    @GetMapping("/provinces")
    public AjaxResult getProvinces()
    {
        List<String> provinces = bizHotelService.getProvinceList();
        return success(provinces);
    }

    /**
     * 根据省份获取城市列表
     */
    @GetMapping("/cities/{province}")
    public AjaxResult getCitiesByProvince(@PathVariable("province") String province)
    {
        List<String> cities = bizHotelService.getCityListByProvince(province);
        return success(cities);
    }

    /**
     * 获取酒店信息详细信息
     */
    @GetMapping(value = "/{hotelId}")
    public AjaxResult getInfo(@PathVariable("hotelId") Long hotelId)
    {
        return success(bizHotelService.selectBizHotelByHotelId(hotelId));
    }

    /**
     * 新增酒店信息
     */
    @Log(title = "酒店信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizHotel bizHotel)
    {
        bizHotel.setCreateBy(getNickname());
        return toAjax(bizHotelService.insertBizHotel(bizHotel));
    }

    /**
     * 修改酒店信息
     */
    @Log(title = "酒店信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizHotel bizHotel)
    {
        bizHotel.setUpdateBy(getNickname());
        return toAjax(bizHotelService.updateBizHotel(bizHotel));
    }

    /**
     * 删除酒店信息
     */
    @Log(title = "酒店信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hotelIds}")
    public AjaxResult remove(@PathVariable Long[] hotelIds)
    {
        return toAjax(bizHotelService.deleteBizHotelByHotelIds(hotelIds));
    }
}
